class code1 {
    //直接变为一维数组二分
    public boolean searchMatrix(int[][] mar, int target) {
        int m = mar.length;
        int n = mar[0].length;

        //二分
        int left = 0;
        int right = m*n-1;
        while(left<right) {
            int mid = left + (right-left)/2;
            if(target <= mar[mid/n][mid%n] ) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return target == mar[left/n][left%n];
    }
}